package com.xsoft.demo2;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import java.util.Random;

public class MainActivity extends AppCompatActivity {
    private TextView marquee;
    private TextView chatTxt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        marquee = findViewById(R.id.marquee);
        marquee.requestFocus();
        chatTxt = findViewById(R.id.chat_txt);
        chatTxt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                chatTxt.setText(chatTxt.getText() + "\n" + "随机数" + new Random().nextInt(100) + "发言");
            }
        });
        //长按清空聊天记录
        chatTxt.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                chatTxt.setText(null);
                return true;
            }
        });
    }
}